#!/bin/sh

# Prevents processing-java from stealing focus, see:
# https://github.com/processing/processing/issues/3996.
OPTION_FOR_HEADLESS_RUN=""
for ARG in "$@"
do
    if [ "$ARG" = "--build" ]; then
        OPTION_FOR_HEADLESS_RUN="-Djava.awt.headless=true"
    fi
done

cd "/Applications/Processing.app/Contents/Java" && /Applications/Processing.app/Contents/PlugIns/jdk1.8.0_202.jdk/Contents/Home/jre/bin/java -Djna.nosys=true $OPTION_FOR_HEADLESS_RUN -cp "ant.jar:ant-launcher.jar:core.jar:jna.jar:pde.jar:jna-platform.jar:core/library/gluegen-rt-natives-linux-armv6hf.jar:core/library/jogl-all-natives-linux-armv6hf.jar:core/library/gluegen-rt-natives-linux-aarch64.jar:core/library/jogl-all-natives-linux-aarch64.jar:core/library/gluegen-rt-natives-macosx-universal.jar:core/library/gluegen-rt-natives-linux-amd64.jar:core/library/jogl-all-natives-linux-i586.jar:core/library/gluegen-rt-natives-windows-i586.jar:core/library/jogl-all.jar:core/library/gluegen-rt-natives-linux-i586.jar:core/library/jogl-all-natives-linux-amd64.jar:core/library/gluegen-rt.jar:core/library/core.jar:core/library/jogl-all-natives-macosx-universal.jar:core/library/jogl-all-natives-windows-i586.jar:core/library/gluegen-rt-natives-windows-amd64.jar:core/library/jogl-all-natives-windows-amd64.jar:modes/java/mode/com.ibm.icu.jar:modes/java/mode/org.eclipse.core.contenttype.jar:modes/java/mode/org.eclipse.core.jobs.jar:modes/java/mode/org.eclipse.text.jar:modes/java/mode/org.eclipse.core.runtime.jar:modes/java/mode/jdtCompilerAdapter.jar:modes/java/mode/classpath-explorer-1.0.jar:modes/java/mode/jdi.jar:modes/java/mode/org.eclipse.equinox.common.jar:modes/java/mode/org.netbeans.swing.outline.jar:modes/java/mode/org.eclipse.osgi.jar:modes/java/mode/JavaMode.jar:modes/java/mode/jsoup-1.7.1.jar:modes/java/mode/antlr.jar:modes/java/mode/jdimodel.jar:modes/java/mode/org.eclipse.core.resources.jar:modes/java/mode/org.eclipse.jdt.core.jar:modes/java/mode/org.eclipse.equinox.preferences.jar" processing.mode.java.Commander "$@"
